<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>jQuery UI Autocomplete - Remote with caching</title>
<script type="text/javascript" language="javascript" src="/static/js/bootstrap.js"></script>
  <style>
  .ui-autocomplete-loading {
    background: white url("images/ui-anim_basic_16x16.gif") right center no-repeat;
  }
  </style>
  <script>
  $(function() {
    console.log("document ready");
    var cache = {};
    $( "#birds" ).autocomplete({
      minLength: 2,
      source: function( request, response ) {
        var term = request.term;
        if ( term in cache ) {
          response( cache[ term ] );
          return;
        }
 
        $.getJSON( "/search.php", request, function( data, status, xhr ) {
          cache[ term ] = data;
          response( data );
        });
      }
    });
    console.log("here");
  });
  </script>
</head>
<body>
 
<div class="ui-widget">
  <label for="birds">Program Language: </label>
  <input id="birds">
</div>
 
 
</body>
</html>